#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
    int n = 0, m = 0, arr[11][11] = { 0 };
    scanf("%d %d", &n, &m);
    int i = 0, j = 0, k = 0, a = 0, b = 0;
    char t = 0;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }
    scanf("%d", &k);
    for (i = 0; i < k; i++)
    {
        scanf(" %c %d %d", &t, &a, &b);
        if (t == 'r')
        {
            for (j = 0; j < m; j++)
            {
                int tmp = arr[a - 1][j];
                arr[a - 1][j] = arr[b - 1][j];
                arr[b - 1][j] = tmp;
            }
        }
        else if (t == 'c')
        {
            for (j = 0; j < n; j++)
            {
                int tmp = arr[j][a - 1];
                arr[j][a - 1] = arr[j][b - 1];
                arr[j][b - 1] = tmp;
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}